﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX.AudioVideoPlayback;

namespace MusicaTangible
{
    public enum Colors { red, orange, yellow, green, lightblue, blue, purple, empty };

    class Instrument
    {
        public enum InstrumentPresets { drums, guitar, bass, piano };
        public String Name {get; set;}
        private Audio[] sounds;

        public Instrument(String name)
        {
            this.Name = name;
            this.sounds = new Audio[Enum.GetNames(typeof(Colors)).Length];
        }

        public Instrument(String name, InstrumentPresets preset)
        {
            this.Name = name;
            this.sounds = new Audio[Enum.GetNames(typeof(Colors)).Length];

            switch (preset)
            {
                case InstrumentPresets.drums:
                    this.sounds[0] = new Audio("Sounds\\Drums\\hihat.wav");
                    this.sounds[1] = new Audio("Sounds\\Drums\\hihat.wav");
                    this.sounds[2] = new Audio("Sounds\\Drums\\hihat.wav");
                    this.sounds[3] = new Audio("Sounds\\Drums\\hihat.wav");
                    this.sounds[4] = new Audio("Sounds\\Drums\\hihat.wav");
                    this.sounds[5] = new Audio("Sounds\\Drums\\kick.wav");
                    this.sounds[6] = new Audio("Sounds\\Drums\\snare.wav");
                    break;
                case InstrumentPresets.guitar:
                    this.sounds[0] = new Audio("Sounds\\Guitar\\guitar_c.wav");
                    this.sounds[1] = new Audio("Sounds\\Guitar\\guitar_d.wav");
                    this.sounds[2] = new Audio("Sounds\\Guitar\\guitar_e.wav");
                    this.sounds[3] = new Audio("Sounds\\Guitar\\guitar_f.wav");
                    this.sounds[4] = new Audio("Sounds\\Guitar\\guitar_g.wav");
                    this.sounds[5] = new Audio("Sounds\\Guitar\\guitar_a.wav");
                    this.sounds[6] = new Audio("Sounds\\Guitar\\guitar_b.wav");
                    break;
                case InstrumentPresets.piano:
                    this.sounds[0] = new Audio("Sounds\\Piano\\piano_c.wav");
                    this.sounds[1] = new Audio("Sounds\\Piano\\piano_d.wav");
                    this.sounds[2] = new Audio("Sounds\\Piano\\piano_e.wav");
                    this.sounds[3] = new Audio("Sounds\\Piano\\piano_f.wav");
                    this.sounds[4] = new Audio("Sounds\\Piano\\piano_g.wav");
                    this.sounds[5] = new Audio("Sounds\\Piano\\piano_a.wav");
                    this.sounds[6] = new Audio("Sounds\\Piano\\piano_b.wav");
                    break;
                case InstrumentPresets.bass:
                    this.sounds[0] = new Audio("Sounds\\Bass\\bass_c.wav");
                    this.sounds[1] = new Audio("Sounds\\Bass\\bass_d.wav");
                    this.sounds[2] = new Audio("Sounds\\Bass\\bass_e.wav");
                    this.sounds[3] = new Audio("Sounds\\Bass\\bass_f.wav");
                    this.sounds[4] = new Audio("Sounds\\Bass\\bass_g.wav");
                    this.sounds[5] = new Audio("Sounds\\Bass\\bass_a.wav");
                    this.sounds[6] = new Audio("Sounds\\Bass\\bass_b.wav");
                    break;
                default:
                    break;
            }
        }

        public void AddSound(Colors color, Audio sound)
        {
            this.sounds[(int)color] = sound;
        }

        public void Play(Colors color)
        {
            if (color != Colors.empty)
            {
                this.sounds[(int)color].Stop();
                this.sounds[(int)color].Play();
            }
        }

    }
}
